package chixing.day08.homework;

public class MyStudent {
    private String name;
    private double score;
    private static int allStu;     //类变量不能让子类修改，所以只能提供get()方法给类变量不能提供set()方法
    private static double allScore;

    public MyStudent(){
        allStu++;       //在创建 无参对象时 让总人数 +1，
    }
    public MyStudent(String name, double score) {
        this.name = name;
        this.score = score;
        allStu++;       //在创建有参对象是 让总人数=1
        allScore += score; //创建对象时把成绩加入到总成绩中
    }

    //方法 getAverageScore() 返回平均分
    public static double getAverageScore() {
        return allScore/allStu;
    }



    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    public static int getAllStu() {
        return allStu;
    }

    public static double getAllScore() {
        return allScore;
    }

    @Override
    public String toString() {
        return "MyStudent{" +
                "name='" + name + '\'' +
                ", score=" + score +
                '}';
    }
}
